import time
import Page
from Page import Launcher
from Base.Base import Base
from selenium.webdriver.common.by import By


class LauncherNumberPage(Base):
    """
    桌面账户密码页面

    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 左侧的home键
        self.number_home_btn = (By.XPATH, Launcher.RESOURCE_ID.format("ivHome"))

        # 左侧的返回键
        self.number_back_btn = (By.XPATH, Launcher.RESOURCE_ID.format('ivBack'))

        # 账户标题
        self.number_title_text = (By.XPATH, Launcher.RESOURCE_ID.format("verify_title"))

        # 删除按钮
        self.number_delete_btn = (By.XPATH, Launcher.RESOURCE_ID.format("iv_delete_password"))

        # 数字键
        self.number_digital_btn = (By.XPATH, Launcher.number_btn.format(""))

        # 登录按钮
        self.number_log_in_btn = (By.XPATH, Launcher.RESOURCE_ID.format("password_confirm_bt"))

        # 忘记密码按钮
        self.number_forget_password_btn = (By.XPATH, Launcher.RESOURCE_ID.format("forget_passwd"))

    def click_home(self):
        """
        点击左侧的home键

        :return:None
        """
        self.click_element(self.number_home_btn)

    def click_back(self):
        """
        点击左侧的back键

        :return:None
        """
        self.click_element(self.number_back_btn)

    def get_title(self):
        """
        获取密码页面标题

        :return:获取元素
        """
        return self.find_element_o(self.number_title_text)

    def click_delete(self):
        """
        点击删除按钮

        :return:None
        """
        self.click_element(self.number_delete_btn)

    def click_log_in(self):
        """
        点击登录按钮

        :return:None
        """
        self.click_element(self.number_log_in_btn)

    def click_forget_password(self):
        """
        点击忘记密码按钮

        :return:None
        """
        self.click_element(self.number_forget_password_btn)

    def click_digital(self, index=1):
        """
        点击数字键

        index 为数字键0-9
        :return:None
        """
        self.number_digital_btn = (By.XPATH, Launcher.number_btn.format(index))
        self.click_element(self.number_digital_btn)

    def is_display_number(self):
        """
        是否进入账户选择页面
        :return:
        """
        return self.is_display(self.number_title_text)
